package com.zzj.ecology.admin.controller.minitor;

import com.zzj.ecology.admin.controller.BaseController;
import com.zzj.ecology.common.constant.LogConstants;
import com.zzj.ecology.common.constant.UrlConstants;
import com.zzj.ecology.framework.annotation.Pagination;
import com.zzj.ecology.system.bean.minitor.SysUserOnline;
import com.zzj.ecology.system.domain.Paging;
import com.zzj.ecology.system.dto.R;
import com.zzj.ecology.system.service.minitor.SysUserOnlineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName SysUserOnlineController
 * @Description TODO
 * @Author zhijun zeng at 11:23 2020/5/23
 * @Version 1.0
 **/
@RestController
@Api(value = "SysUserOnline", description = "SysUserOnline 在线用户信息")
public class SysUserOnlineController extends BaseController {

    @Autowired
    private SysUserOnlineService sysUserOnlineService;

    @ApiOperation(value = "获取在线用户数量", notes = "获取在线用户数量，用户 online 标记的用户", httpMethod = "GET")
    @RequestMapping(value = UrlConstants.UserOnlineUrl.ONLINE_SESSIONS, method = RequestMethod.GET)
    public R onlineSessions(@Pagination Paging paging) {
//        return success().add(sysUserOnlineService.findSessionsByStatus(LogConstants.OnlineLog.STATUS_ONLINE));
        startPaging();
        List<SysUserOnline> list = sysUserOnlineService.findSessionsByStatus(LogConstants.OnlineLog.STATUS_ONLINE);
        return R.ok().setData(list);
    }

}
